#ifndef VISIBILITYMETERFORM_H
#define VISIBILITYMETERFORM_H

#include <QWidget>
#include <QBarSet>
#include <QBarSeries>
#include <QValueAxis>
#include <QBarCategoryAxis>
#include <QChartView>
#include <QLineSeries>
#include <QTimer>
#include <QRandomGenerator>
#include <QThread>
#include <QSplineSeries>
#include <QDateTime>
#include <QStandardItemModel>
#include <QMutex>

namespace Ui {
class VisibilityMeterForm;
}


class VisibilityProtocol
{
public:
    int one_minute_visibility;
    int ten_minute_visibility;
    int TheIntensityOfEmittedEnergy;
    int TheIntensityOfReceivedEnergy;
    int RatedPower;
    QString device_code;
    QDateTime date_time;
};


class VisibilityMeterForm : public QWidget
{
    Q_OBJECT

public:
    explicit VisibilityMeterForm(QWidget *parent = nullptr);
    ~VisibilityMeterForm();

public:
    void InitTreeView();
    void InitChart();

signals:
    void updateView(VisibilityProtocol);

private:
    Ui::VisibilityMeterForm *ui;
    QChart *m_chart;
    QStandardItemModel m_model;
    QDateTime m_startTime;
    QThread* m_thread;

    //用于维护chart的y轴范围，m_visYMax[0]为所以能见度中的最大，之后为可能最大的能见度，是一个递减数组
    //m_visYMax[0]为所有能见度中的最小，之后的元素为可能最小的能见度，是一个递增数组，
    QVector<int> m_visYMax;
    QVector<int> m_visYMin;
};

#endif // VISIBILITYMETERFORM_H
